<div class="dashboard_item">
    <h1>Brugere</h1>
    <table id="userList">
        <tr>
            <td>Brugernavn</td>
            <td>Navn</td>
            <td>Brugergruppe</td>
            <td>Kodeord</td>
            <td>Slet</td>
        </tr>
    {foreach from=$UserList item=u key=k}
        <tr>
            <td>{$k}</td>
            <td><input type="textbox" value="{$u.name}" name="old[{$k}][name]" /></td>
            <td>
                <select name="old[{$k}][group]">
                    {foreach from=$GroupList item=g}
                <option value="{$g.id}" {if $g.id == $u.permissions.id}selected="selected"{/if}>{$g.id}</option>
                    {/foreach}
                </select>
            </td>
            <td><input type="password" value="" name="old[{$k}][password]" /></td>
            <td>{if $u.deleteable}<input type='checkbox' name='old[{$k}][delete]' value='TRUE' />{/if}</td>
        </tr>
    {/foreach}
    </table>
        <input type="button" onclick='addUser()' value="Tilføj bruger" /><br/>
        <input type="submit" value="gem" />
{literal}
<script type="text/javascript">
    i = 0;
    function addUser(){

        $('#userList tr:last').after('<tr><td><input type="textbox" name="new['+i+'][id]" /></td><td><input type="textbox" name="new['+i+'][name]" /></td><td> {/literal}<select name="new['+i+'][group]">{foreach from=$GroupList item=g}<option value="{$g.id}" >{$g.id}</option>{/foreach}</select>{literal}</td><td><input type="password" name="new['+i+'][password]" /></td><td></td></tr>');
        i++;
    }
</script>
{/literal}
</div>